﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Xml;
namespace Tracy.CoreLib.Data
{
    public partial class RssModel : XmlModel_AutoParseFunctions
    {
        public class RssItem : XmlModel_AutoParseFunctions, IXmlModelItem
        {
            #region 构造函数
            public RssItem() : base() { }
            public RssItem(string xml) : base(xml) { }
            public RssItem(XmlNode rssnode) : base(rssnode) { }
            #endregion

            
            public string Title
            {
                get { return Data[Constants.CONST_TAG_TITLE]; }
            }

            public string Description
            {
                get 
                {
                    if (Data.ContainsKey(Constants.CONST_TAG_DESCRIPTION)) return Data[Constants.CONST_TAG_DESCRIPTION];
                    else return "";
                }
            }

            public string Link
            {
                get { return Data[Constants.CONST_TAG_LINK]; }
            }

            public string Key
            {
                get
                {
                    return Title;
                }
            }
            public string XmlNodeName
            {
                get
                {
                    return Constants.CONST_TAG_ITEM;
                }
            }

            protected override void PreParseXml(XmlNode node)
            {
                Data[Constants.CONST_TAG_TITLE] = SelectNode(node, Constants.CONST_TAG_TITLE, true).InnerText;
                //Data[Constants.CONST_TAG_DESCRIPTION] = SelectNode(node, Constants.CONST_TAG_DESCRIPTION, false).InnerText;
                Data[Constants.CONST_TAG_LINK] = SelectNode(node, Constants.CONST_TAG_LINK, true).InnerText;
            }
        }

    }
}